procedure_sql = "CREATE PROCEDURE proc() " \
                "update clouddb_tmp set tenant_user='test' where act_id=6;" \
                "update clouddb_tmp set tenant_user='test' where act_id=7;" \
                "END PROCEDURE"

procedure_sql2 = "CREATE PROCEDURE proc2() " \
                "EXECUTE FUNCTION task('storagepool purge errors');" \
                "EXECUTE FUNCTION task('storagepool add', '/storagepool1','0', '0', '256MB', '1');" \
                "END PROCEDURE"


test_update = "update clouddb_tmp set tenant_user='test' where act_id=5"

trigger_sql = "CREATE TRIGGER test_trigger UPDATE OF tenant_status ON clouddb_tmp REFERENCING NEW AS post " \
              "FOR EACH ROW WHEN (post.tenant_status='Error')( EXECUTE PROCEDURE proc())"

trigger_sql2 = "CREATE TRIGGER test_trigger2 UPDATE OF status ON storagepool REFERENCING NEW AS post " \
              "FOR EACH ROW WHEN (post.status='Error')(EXECUTE PROCEDURE proc2())"

# EXECUTE PROCEDURE proc1() WITH TRIGGER REFERENCES
exec_trigger = "update clouddb_tmp set tenant_status='%s' where act_id=6;"%"Error"
check_trigger = "select * from systriggers;"

check_trigger_content = "select * from systrigbody"
drop_tigger = "drop trigger test_trigger"
drop_procedure = "DROP PROCEDURE proc2"

show_clouddb_tmp = "select * from storagepool"

check_space_size = "select " \
                   "sysdbstab.name," \
                   "sum(syschktab.chksize*2048) total," \
                   "sum(chksize - nfree)*2048 nused," \
                   "sum(syschktab.nfree*2048) free from syschktab, sysdbstab " \
                   "where syschktab.dbsnum = sysdbstab.dbsnum group by 1 ;"


expand_space = "EXECUTE FUNCTION task('modify space expand', '71', '2 GB');"
import informixdb
with informixdb.connect('sysadmin', "informix", "zxcasd123", autocommit=True) as conn:
    with conn.cursor() as cur:
        cur.execute("EXECUTE FUNCTION task('storagepool add', '/data/dbs/storagepool','0', '0', '256MB', '1');")
    # cur.execute(show_clouddb_tmp)
        for i in cur.fetchall():
            print i
    #('d_1472473550613258_dbs_y3mjlv0ik0', Decimal('268435456'), Decimal('5318656'), Decimal('263116800'))
# import informixdb
# with informixdb.connect('sysmaster', "informix", "zxcasd123", autocommit=True) as conn:
#     with conn.cursor() as cur:
#         cur.execute(check_space_size)
#         for i in cur.fetchall():
#             print i
